import { VNode } from './vnode/main.js'

const ops = Object.prototype.toString

export function isType (item){
    return ops.call(item).slice(8, -1)
}

export function isObj(obj){
    return isType(obj) === 'Object'
}

export function isArr(arr){
    return Array.isArray(arr)
}

export function isUnd(und){
    return typeof und === 'undefined'
}

export function isStr(str){
    return isType(str) === 'String'
}

export function isText(text){
    return isType(text) === 'Text'
}

export function getVal(vm, val){
    let arr = val.split('.')
    return arr.reduce((now, i) => {
        return now[i]
    }, vm)
}

export function isVNode(vnode) {
    return vnode instanceof VNode
}

export function isUndef (v) {
    return v === undefined || v === null
}

export function isEle(el) {
    return ops.call(el).slice(-8, -1) === 'Element'
}
